#include "odbc/connection.hpp"
#include "odbc/environment.hpp"
#include "odbc/odbc_error.hpp"
#include "mysql_test_fixture.hpp"
#include "../odbc_test_defs.hpp"
#include <boost/test/auto_unit_test.hpp>

namespace
{

using namespace odbc;
using namespace odbc_tests;

// ---------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE( testSuccessfulConnection)
{
	ODBCTEST_CHECK_NOTHROW( mysql_test_fixture());
}

// ---------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE( testAutoCommit)
{
	mysql_test_fixture auto_f( true);
	mysql_test_fixture nauto_f( false);

	BOOST_CHECKPOINT( "Testing autocommit flag initialization");
	ODBCTEST_CHECK_NOTHROW( BOOST_CHECK_EQUAL( true, auto_f.conn().autocommit()));
	ODBCTEST_CHECK_NOTHROW( BOOST_CHECK_EQUAL( false, nauto_f.conn().autocommit()));

	// TODO: Test autocommit effect: 
	// Scenarios:
	// Autocommit=false: make an insert, then rollback. Expect the insert not performed.
	// Autocommit=true: make an insert, then rollback. Expect the insert performed.
}

// ---------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE( testCommitRollback)
{
	// TODO: Test
	// Autocommit=false (so no interference)
	// Scenarios:
	// Make an insert. Commit. Rollback. Expect insert performed.
	// Make an insert. Rollback. Commit. Expect insert not performed.
}

} // namespace
